using System;
using System.Linq;
using System.Linq.Expressions;
using Caramel.Linq;

namespace Caramel
{
	public static class RepositoryExtensions
	{
		public static void Delete<T>(this IRepository<T> repository, object id) where T : class
		{
			repository.
				Delete(
					repository.
						Get(id)
				);
		}

		public static void DeleteAll<T>(this IRepository<T> repository, Expression<Func<T, bool>> predicate) where T : class
		{
			repository.All.
				Where(predicate).
				Each(e => repository.Delete(e));
		}
	}
}
